package com.qiji.video.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qiji.video.bean.VideoPartition;
import com.qiji.video.bean.Videos;
import com.qiji.video.bean.vo.VideosAllVo;
import com.qiji.video.bean.vo.VideosSearchVo;
import com.qiji.video.mapper.extend.VideoPartitionExtendMapper;
import com.qiji.video.mapper.extend.VideosExtendMapper;
import com.qiji.video.service.IVideoDisplayService;
import com.qiji.video.util.Result;
import com.qiji.video.util.ResultUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VideoDisplayServiceImpl implements IVideoDisplayService {

    @Resource
    private VideosExtendMapper videosExtendMapper;

    @Resource
    private VideoPartitionExtendMapper partitionExtendMapper;

    @Override
    public List<VideosSearchVo> hotSearch() {
        return videosExtendMapper.hotSearch();
    }

    @Override
    public PageInfo<VideosAllVo> pageInfoByName(Integer pageNum, Integer pageSize, String name) {

        PageHelper.startPage(pageNum,pageSize);
        List<VideosAllVo> videos = videosExtendMapper.selectVideosByName(name);
        return new PageInfo<>(videos);
    }

    @Override
    public List<Videos> carouselSelect(Integer id) {


        return videosExtendMapper.carouselSelect(id);
    }
    //查询分区
    @Override
    public  List<VideoPartition> selectPartition(){
        return partitionExtendMapper.selectPartition();
    }
    //查询分区类型
    @Override
    public Result selectPartitionType(Integer id){
        if(id == 0){
            return ResultUtil.success(partitionExtendMapper.selectAll());
        }
        else {
            return ResultUtil.success(partitionExtendMapper.selectPartitionTypeOther(id));
        }

    }
    //视频展示
    @Override
    public List<Videos> selectPartitionVideos(Integer id, Integer state){
        return partitionExtendMapper.selectPartitionVideos(id, state);
    }

    @Override
    public List<Videos> mayLike(Integer id) {
        return partitionExtendMapper.selectMayLikes(id);
    }
}
